<template>
  <el-container>
    <el-header style="border-bottom: 1px solid rgba(255,255,255,0.12)">
      <p style="font-family: MicrosoftYaHei;font-size: 16px;color: #7DDAFF;">维修信息列表</p>
    </el-header>
    <el-main>
      <el-row class="btnGroup">
        <el-button class="twoBtn" @click="addBerth"><span>导出</span><i class="el-icon-download"></i></el-button>
        <!--<el-button icon="el-icon-edit" @click="editBerth">编辑</el-button>-->
        <!--<el-button class="twoBtn" @click="delBerth"><span>删除</span><i class="el-icon-delete"></i></el-button>-->
        <!--<el-button icon="el-icon-download">导出EXCEL</el-button>-->
      </el-row>
      <el-table
        :data="tableData.list"
        ref="multipleTable"
        element-loading-background="rgba(0, 0, 0, .3)"
        height="500"
        :row-class-name="tableRowClassName"
        style="width: 100%;padding-top: 0px;background-color: #1B4685"
        @selection-change="handleSelectionChange"
        v-loading="loading"
      >
        <el-table-column fixed align="center" type="selection" width="55"></el-table-column>
        <el-table-column fixed sortable align="center" prop="equipment_no" label="设备编号" width="180"></el-table-column>
        <el-table-column sortable align="center" prop="equipment_site" label="设备位置" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="equipment_type" label="设备类型" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="equipment_model" label="设备型号" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="equipment_model" label="设备厂商" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="repair_problem_desc" label="故障描述" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="equipment_operator" label="维修单位" width="170"></el-table-column>
        <el-table-column sortable align="center" prop="equipment_person" label="联系人" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="equipment_phoneno" label="联系方式" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="repair_time" label="维修时间" width="150"></el-table-column>
        <el-table-column sortable align="center" prop="repair_time" label="维修状态" width="150"></el-table-column>
        <el-table-column fixed="right" align="center" width="100" label="操作">
          <template slot-scope="scope">
            <el-dropdown trigger="click" @command="handleCommand">
              <el-button class="downBtn" @click="changeRow(scope.row)">
                <i class="el-icon-arrow-down"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="edit">编辑</el-dropdown-item>
                <el-dropdown-item command="del">结束工单</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
    </el-main>
    <el-footer>
      <el-pagination
        background
        layout="total,sizes,prev,pager,next,jumper"
        :total="dataCount"
        :page-sizes="[10,20,30,50]"
        :page-size="dataPageSize"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
        style="margin-top: 16px;"
      ></el-pagination>
    </el-footer>
  </el-container>
</template>

<script>
  /* eslint-disable */
  export default {
    name: 'repairMagTable',
    props: ['tableLoad', 'tableData'],
    data() {
      return {
        changeVal: '',
        dataCount: 0,
        dataPageSize: 10,
        multipleTable: [],
        loading: false,
        pageNum: 0,
        tempParkMag: {
          park_no: '',
          park_name: '',
          park_placeno: '',
          park_placeStart: '001',
          park_ssdw: '',
          park_ssdwname: '', park_sfbzname: '',
          park_sfbz: '', park_roadno: '', park_road: '', park_dllx: '',
          park_jdbsc: '', park_sroad: '', park_eroad: '', park_dlnc: '',
          park_sffs: '', park_jcfs: '', park_long: '', park_lati: '',
          park_sdate: '', park_edate: '', park_status: '1', park_remark: '',

          equipment_site: '',
          equipment_desc: '',
          equipment_status: '',
          equipment_type: '',
          equipment_person: '',
          equipment_phoneno: '',
          equipment_model: '',
          equipment_manager: '',
          equipment_operator: '',
          equipment_buy_time: '',
          equipment_long: '',
          equipment_lati: '',
          repair_time: '',
          repair_problem_desc: ''
        }
      }
    },
    watch: {
      tableLoad: function (val) {
        this.loading = val
      },
      tableData: function (val) {
        this.dataCount = val.count
        this.dataPageSize = val.pageSize
      }
    },
    methods: {
      addBerth: function () {
        this.$emit('addBerth', true)
      },
      editBerth: function () {
        if (this.multipleTable.length !== 1) {
          this.$message({
            message: '请选择一条记录',
            type: 'warning'
          })
          return
        }
        this.$emit('editBerth', [this.multipleTable[0], true])
      },
      delBerth: function () {
      },
      handleSelectionChange: function (val) {
        this.multipleTable = val
      },
      handleCurrentChange: function (val) {
        this.$emit('pageNum', val)
      },
      handleSizeChange: function (val) {
        this.$emit('pageSize', val)
      },
      handleCommand(val) {

      },
      changeRow(val) {
        this.changeVal = Object.assign({}, val) // copy obj
      }
    }
  }
</script>

<style scoped>
  .el-dropdown {
    width: 33px;
    height: 19px;
  }

  .el-dropdown > .el-button {
    width: 33px;
    height: 19px;
    padding: 3px 9px;
  }

  .el-main {
    padding: 0;
    margin-top: 24px;
    margin-left: 24px;
  }

  .el-header p {
    font-family: MicrosoftYaHei;
    font-size: 13px;
    margin-top: 22px;
    color: #7F8CA6;
  }

  .el-header {
    padding: 0;
    margin-left: 24px;
    margin-right: 24px;
    border-bottom: 1px solid #E1E1E1;
  }

  .btnGroup {
  }

  .btnGroup > .twoBtn {
    width: 64px;
    height: 24px;
    padding: 4px 20px;
    border: 1px solid #409eff;
    font-family: MicrosoftYaHei;
    color: #fff;
    font-size: 12px;
  }

  .btnGroup > .fourBtn {
    width: 64px;
    height: 24px;
    padding: 4px 8px;
    border: 1px solid #409eff;
    font-family: MicrosoftYaHei;
    color: #fff;
    font-size: 12px;
  }

  .btnGroup > .el-button span {
    display: none;
  }

  .btnGroup > .el-button:hover {
    background-color: #409EFF;
  }

  .btnGroup > .el-button:hover span {
    display: block;
  }

  .btnGroup > .el-button:hover i {
    display: none;
  }

  .el-button i {
    color: #409eff;
  }

  .el-footer {
    text-align: right;
  }
</style>
